<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'index-area', //页面标示
    'pagename' => '', //当前页面名称
    'mycss' => array('mobile/style'), //加载的css样式表
    'myjs' => array('global/jquery-1.9.0.min'), //加载的js脚本
    'footerjs'=>array(),
    'head'=>true//是否加载头部文件
);
include getTpl('header', 'public');
?>
<style type="text/css">
    .select_wr .on {
        color: #fff;
        background: #3399fe;
    }
</style>
<body>
<div>
    <div class="select_type" >
        <a href="javascript:;" class="on" >游戏大区</a>
        <a href="javascript:;">游戏服务器</a>
        <a href="javascript:;">物品类型</a>
        <a href="javascript:;">交易身份</a>
    </div>
    <div class="select_game  ">
        <div  class="select_wr s1 active">
            <?php if(isHave($areas)){ ?>
                <?php foreach ($areas as $k => $v): ?>
                    <div onclick="getServer(this)" data-id="<?php echo $v['id'] ?>" ><?php echo $v['area_name'] ?></div>
                <?php endforeach ?>
            <?php } ?>
        </div>
        <div  class="select_wr s2">
        </div>
        <div  class="select_wr s3">
            <?php if(isHave($stdmodes)){ ?>
                <?php foreach ($stdmodes as $k => $v): ?>
                    <div onclick="getIdent(this)" data-abri="<?php echo $v['abridge'] ?>"><?php echo $v['name'] ?></div>
                <?php endforeach ?>
            <?php } ?>
        </div>
        <div  class="select_wr">
            <div onclick="chooseIdent(this)" data-abri="buyer">买家</div>
            <div onclick="chooseIdent(this)" data-abri="seller">卖家</div>
        </div>
    </div>
</div>
<?php 
    $action = $_GET['sign'] == 'hq' ? U('index/records') : U('index/search');
?>
<form id="postForm" action="<?php echo $action ?>" method="post">
    <!-- 游戏编码 -->
    <input type="hidden" name="gm" value="<?php echo $gm ?>"> 
    <!-- 区服编码 -->
    <input type="hidden" name="ar">
    <!-- 物品类型 -->
    <input type="hidden" name="ty">
    <!-- 身份 -->
    <input type="hidden" name="cr">
</form>

<script>
    $(function(){
        $(".select_type a").click(function(){
            var num=$(this).index();
            $(this).addClass("on").siblings("a").removeClass("on");
            $(".select_wr").eq(num).addClass("active").siblings(".select_wr").removeClass("active");
            $(".select_game").get(0).className = 'select_game';
            $(".select_game").addClass("w"+(num*1+1));
        })

        $(".select_wr div").click(function(){
            $(this).addClass('on').siblings().removeClass('on');
            $(this).parents(".select_wr ").removeClass("active").next(".select_wr").addClass("active");
            $(".select_game").get(0).className = 'select_game';
            var num=$(this).parents(".select_wr").index();
            $(".select_type a").eq(num+1).addClass("on").siblings("a").removeClass("on");
        })

        $(".s1 div").click(function(){
            $(".select_game").addClass("w2");

        })

        // $(".s2 div").click(function(){
        //     $(".select_game").addClass("w3");
        // })

        $(".s3 div").click(function(){
            $(".select_game").addClass("w4");
        })
    })

    //获取服信息
    function getServer(obj) {
        var area_id = $(obj).attr('data-id');
        $.getJSON("<?php echo U('index/getServerByAreaId') ?>" , {area_id , area_id}, function(result){
            if(result.status == 1){
                $(".s2").html(result.data);
            }
        });
    }

    function getGameType(obj) {
        $("input[name='ar']").val($(obj).attr('data-abri'));
        $(obj).addClass('on').siblings().removeClass('on');
        $(obj).parents(".select_wr ").removeClass("active").next(".select_wr").addClass("active");
        $(".select_game").get(0).className = 'select_game';
        $(".select_game").addClass("w3");
        $(".select_type a").eq(2).addClass("on").siblings("a").removeClass("on");
    }

    function getIdent(obj) {
        $("input[name='ty']").val($(obj).attr('data-abri'));
    }

    //跳转
    function chooseIdent(obj) {
        $("input[name='cr']").val($(obj).attr('data-abri'));
        var g = $("input[name=gm]").val();
        var a = $("input[name=ar]").val();
        var t = $("input[name=ty]").val();
        var c = $("input[name=cr]").val();
        if(!g || !a || !t || !c) {
            return false;
        }
        $("#postForm").submit();
    }
</script>
</body>
</html>
